/**
 * 对话记录表
 */
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var objectId = Schema.ObjectId;
var constant = require('../../config/constant');
var logAccessType = constant.LogAccessType;
var readStatus = constant.ReadStatus;
var BaseSchema = require('./base_schema');

var sessionLogSchema = new BaseSchema({
    interlocutorId: {type: String},                          // 对话人ID
    interlocutorIdentity: {type: Number},                    // 对话人身份(0: 系统账户/医生; 10: 用户)
    questionId: {type: objectId},                            // 问题ID
    log: {type: [String]},                                   // 记录
    readStatus: {type: Number, default: readStatus.UNREAD}, // 对话的对方是否已读该记录(0: 未读; 1: 已读)
    access: {type: Number, default: logAccessType.PUBLIC},  // 访问类型(0: 只有用户才能看到; 1: 只有医生才能看到; 2: 只有对话的双方才能看到; 3: 所有人都能看到)
    address: {type: String}                                  // 客户端地址
});
module.exports = mongoose.model('session_log', sessionLogSchema);

